Introduction


2021 Changes to carbon monitoring in MMSD’s surface water monitoring program


MMSD has been monitoring Total Carbon (TC), Total Organic Carbon (TOC), Total Dissolved Organic Carbon (TDOC), and Total Inorganic Carbon (TIC) for over 40 years at nearly 100 sites. In 2020, it was discovered that the MMSD Laboratory’s carbon instrument needed to be replaced at a significant cost. However, this historical data set can be used to guide future monitoring decisions and it was determined that monitoring for carbon could be reduced while meeting MMSD’s monitoring needs.

Different Measures of Carbon. Total carbon is comprised of organic and inorganic portions, where the majority is in the inorganic form, and the total organic portion is predominately in the dissolved form. This leads to high correlations between TC and TIC, as well as between TOC and TDOC. We choose to further investigate potential surrogate parameters for TIC and TOC to determine if any of the parameters were independent of each other and would require continued monitoring. In river and creek sites, TIC was highly correlated with dissolved parameters: specific conductance, alkalinity, hardness, Ca, Mg, total solids, etc., whereas TOC had less relationships, the best being TKN (includes organic N) but nothing stood out as particularly strong, i.e., more independent. Looking at harbor data, both carbon species had moderate correlations with most other parameters while the lake data did not produce any. Looking at these results, TOC appears to be a more independent measure than TIC and would bring the most value of the four carbon species. Furthermore, TOC is routinely sampled in many other monitoring programs and can also be used as a sewage indicator along with other parameters.

Sampling Frequency. Data were summarized by waterbody and month to investigate any season shifts in TOC results that may dictate important times for collecting carbon data and to ensure the full range of annual variation is captured. All locations exhibited a similar pattern: increases beginning in March through May/June, followed by a decrease that remains steady until a small increase in October that remains through December. The pattern fits neatly into a quarterly sampling strategy targeting the full range of values.

Number of Sites. Sites were compared to one another to assess similarities or differences to aid in prioritizing certain sites over others. Data were summarized in boxplots by site and compared by waterbody. Additionally, cluster analysis and multidimensional scaling were run using all carbon results as inputs to produce dendrograms and scatterplots, respectively, that compare sites based on similarity. The groups or clusters from these were cross referenced with TOC boxplots to validate the results, using knowledge of the sites and professional judgement when needed. Several sites stand out having unique carbon characteristics when compared to more closely spaced downstream sites, e.g, significantly higher or lower results compared to rest of waterbody. Harbor sites within the breakwater and . Open-lake sites all had very consistent values regardless of location. These results indicated the potential for reducing the number of sampling locations while still being able to characterize the water quality of these dynamic waterbodies.

Recommendations

Based on the conclusions above the following plan is recommended:

  • Sample quarterly (March, June, September, and November) the months selected are based on seasonal changes in values to represent the variation seen throughout the year and months when creeks and lake surveys are also collected.
  • Monitor for TOC only during the quarterly sampling.
  • Quarterly sample collection will occur at 31 sites (Table 1) that are prioritized based on:
  1. “Paired Sites” or sites with grab samples that are at or near USGS gaging stations and/or USGS Core Eco Sites (MMSD funded Corridor Study).
  2. A minimum of 1 site per waterbody and additional sites with unique TOC results.
  3. Sites at the Jones Island and South Shore WRFs outfalls and a reference site in the harbor and/or lake.
  • In addition to quarterly sampling, sample all “CP” surveys (wet, dry and overflow events) with no site reduction due because these surveys provide a good baseline and there is more variability in the results. Monitor for TOC and TIC only.
library(mmsd.wq)
library(tidyverse)


LIMS<-make_dbConnection("LIMS")

pull_lims <- function(start,end){

DBI::dbGetQuery(
  LIMS,
  paste(
    "SELECT * FROM dbo.fFreshwaterMonitoringDetailOpSID(",
    "NULL",
    ",",
    format_for_sql(paste(start,"-01-01",sep = "")),
    ",",
    format_for_sql(paste(end,"-12-31",sep = "")),
    ",0,0,1)",
    sep = ""
  )
) 
}

data1 <- pull_lims(2017,2020)
data2 <- pull_lims(2012,2016)
data3 <- pull_lims(2009,2011)
data4 <- pull_lims(2004,2008)
data5 <- pull_lims(2002,2003)


wq_data_raw <- bind_rows(data1,data2,data3,data4,data5)


#close database connection and remove null pointer
odbc::dbDisconnect(LIMS)
rm(LIMS)
rm(data1,data2,data3,data4,data5,pull_lims)


#get op_sid lookup table 
LIMS <-odbc::dbConnect(odbc::odbc(), Driver = "SQL Server", 
                       Server = "SQLSTD\\LIMS", Database = "LIMS", 
                       Trusted_Connection = "True")

lookup_table <- DBI::dbGetQuery(LIMS,"SELECT * FROM dbo.OPERATION") 
odbc::dbDisconnect(LIMS)
rm

op_sid20 <- 
  wq_data_raw %>%
  filter(lubridate::year(COLLECTION_DATE) == 2020) %>%
  distinct(OP_SID) %>%
  pull()


wq_data_long <- wq_data_raw%>%
  #add parameter names
  dplyr::left_join(
  lookup_table %>%
    dplyr::select(OP_SID,OP_NAME) %>%
    dplyr::rename(parameter = OP_NAME)) %>%
  #add spatial information
  dplyr::left_join(mmsd_wq_sites %>%
              dplyr::select(Site,
                     SiteType,
                     Latitude,
                     Longitude,
                     WaterBody) %>%
              dplyr::rename(SITECODE = Site))%>%
  #add source code type and groups
  dplyr::left_join(source_code_lookup%>%
              dplyr::rename(SOURCE_CODE_SID = source_code_sid)%>%
              dplyr::select(survey_type,
                     survey_group,
                     SOURCE_CODE_SID)%>%
              dplyr::distinct())%>%
  #create a month,depth, and date_survey column
  dplyr::mutate(Month = lubridate::month(COLLECTION_DATE,
                                  label = TRUE,
                                  abbr = TRUE),
         Depth = stringr::str_sub(SITE_CODE,6,6),
         date_survey = paste(COLLECTION_DATE,SURVEY_NUM,sep = " - "))%>%
  #filter unwanted parameters
  dplyr::filter(!OP_SID %in% c(218,180,188,176) &
                  OP_SID %in% op_sid20)%>%
  #clean column names
  janitor::clean_names()

#pivot data wide
wq_data_wide <- 
  wq_data_long%>%
  dplyr::select(
         sample_sid,
         collection_date,
         site_code,
         survey_num,
         site_type,
         parameter,
         reading_raw)%>%
  tidyr::pivot_wider(names_from = parameter,values_from = reading_raw)%>%
  janitor::clean_names()

save.image("wq_data.Rdata")

Selected Carbon Sites

tibble(
  Site = c(
    "CC-01",
    "FC-02",
    "HC-03",
    "IC-04",
    "LC-04",
    "ML-02",
    "NS-03*",
    "OC-01",
    "OC-03",
    "OC-05",
    "OH-01*",
    "OH-02*",
    "OH-03*",
    "OH-14*",
    "RI-01",
    "RI-04",
    "RI-09",
    "RI-11*",
    "RI-13",
    "RI-14*",
    "RI-16",
    "RI-33",
    "RI-35",
    "RI-36",
    "RI-38",
    "RR-04",
    "RR-05",
    "SB-04",
    "SS-01*",
    "UC-03",
    "UC-05",
    "UC-07"
  )
) %>%
  mutate(
    USGS_Site = case_when(
      Site %in% c(
        "CC-01",
        "HC-03",
        "LC-04",
        "ML-02",
        "OC-05",
        "OH-01*",
        "RI-01",
        "RI-04",
        "RI-09",
        "RI-11*",
        "RI-13",
        "RI-16",
        "RI-35",
        "RR-04",
        "RR-05",
        "UC-03",
        "IC-05",
        "UC-07"
      ) ~ "X"
    ),
    Unique_Site = case_when(
      Site %in% c(
        "FC-02",
        "IC-04",
        "OC-01",
        "OC-03",
        "OH-03*",
        "RI-14*",
        "RI-33",
        "RI-36",
        "RI-38",
        "SB-04"
      ) ~ "X"
    ),
    Outfall_OR_Reference = case_when(Site %in% c("NS-03*", "OH-02*", "OH-14*", "SS-01*") ~ "X")
  ) %>%
  DT::datatable()

*multiple depths

Carbon Site Map

 carbon_sites <- mmsd_wq_sites%>%
  filter(carbon_site_flag == "yes")%>%
  st_as_sf(coords = c("Longitude","Latitude"),crs = 4326)%>%
  st_transform(crs = 3071)%>%
  st_buffer(dist = 100)%>%
  st_transform(crs = 4326)

    site_col <- leaflet::colorFactor(rainbow(14, alpha = 1), 
        mmsd_wq_sites$WaterBody)

    leaflet() %>%
            leaflet::addPolylines(
        data = mke_rivers,
        color = "blue",
        popup = ~ paste("<b> River: </b>", ROW_NAME,
                        "<b> River ID </b>", SW_NO)
      )%>%
      addPolygons(
        data = carbon_sites,
        popup = ~ Site,
        color = ~ site_col(WaterBody)
      ) %>%
      addProviderTiles(provider = providers$Esri.WorldImagery) %>% 
      leaflet::addLegend(
        "bottomright",
        pal = site_col,
        values = mmsd_wq_sites$WaterBody,
        title = "Waterbody Type",
        opacity = 1)

Correlations - Spearman

Spearman Correlations

Spearman correlations were calculated according to the methods described in the Introduction. Results for each grouping are displayed below. For the graphs, point size and color correspond to the correlation coefficient. Large blue points indicate a strong positive correlation. Small red dots indicate a strong negative correlation.


Full Data
corr_matrix <- corr_calc(corr_method = "spearman")
## 
## Correlation method: 'spearman'
## Missing treated using: 'pairwise.complete.obs'
   DT::datatable(
      corr_matrix,
      extensions = 'Buttons',
      selection = list(target = 'column'),
      options = list(
        buttons = c('copy', 'csv', 'excel')))
corr_plots(corr_matrix)

River Data
corr_matrix <- corr_calc(corr_method = "spearman",group = "River")
## 
## Correlation method: 'spearman'
## Missing treated using: 'pairwise.complete.obs'
   DT::datatable(
      corr_matrix,
      extensions = 'Buttons',
      selection = list(target = 'column'),
      options = list(
        buttons = c('copy', 'csv', 'excel')))
corr_plots(corr_matrix)

Lake Data
corr_matrix <- corr_calc(corr_method = "spearman",group = "Lake")
## 
## Correlation method: 'spearman'
## Missing treated using: 'pairwise.complete.obs'
   DT::datatable(
      corr_matrix,
      extensions = 'Buttons',
      selection = list(target = 'column'),
      options = list(
        buttons = c('copy', 'csv', 'excel')))
corr_plots(corr_matrix)

Harbor Data only
corr_matrix <- corr_calc(corr_method = "spearman",group = "Harbor")
## 
## Correlation method: 'spearman'
## Missing treated using: 'pairwise.complete.obs'
   DT::datatable(
      corr_matrix,
      extensions = 'Buttons',
      selection = list(target = 'column'),
      options = list(
        buttons = c('copy', 'csv', 'excel')))
corr_plots(corr_matrix)

Outfall Data only
corr_matrix <- corr_calc(corr_method = "spearman",group = "Outfall")
## 
## Correlation method: 'spearman'
## Missing treated using: 'pairwise.complete.obs'
   DT::datatable(
      corr_matrix,
      extensions = 'Buttons',
      selection = list(target = 'column'),
      options = list(
        buttons = c('copy', 'csv', 'excel')))
corr_plots(corr_matrix)

Carbon Summary Table

Carbon Summaries

Data were summarized to better understand dynamics in carbon. These summaries are presented below in a table, figures, and a map. All “widgets” are interactive and can be manipulated directly using the mouse. Likewise, the data that is displayed can be filtered using the dropdown menus.

Carbon Summary Table


Table Description
Carbon data were grouped by parameter, site, and month. Summary statistics were calculated on these groups.

carbon_summary <- wq_data_long %>%
  dplyr::filter(grepl('Carbon', parameter)) %>%
  drop_na(reading_raw) %>%
  dplyr::group_by(parameter, site_code) %>%
  dplyr::summarise(
    mean = mean(reading_raw, na.rm = TRUE),
    median = median(reading_raw, nm.rm = TRUE),
    sd =  stats::sd(reading_raw),
    min = median(reading_raw),
    max = max(reading_raw, nm.rm = TRUE)
  ) %>%
  ungroup() %>%
  mutate(Site = stringr::str_sub(site_code, 1, 5)) %>%
  left_join(mmsd_wq_sites %>%
              select(Site,
                     WaterBody)) %>%
  relocate(Site, .before = site_code) %>%
  relocate(WaterBody, .after = Site)
## `summarise()` regrouping output by 'parameter' (override with `.groups` argument)
## Joining, by = "Site"
carbon_summary_shared <- crosstalk::SharedData$new(carbon_summary)


bscols(
  crosstalk::filter_select(
    "carbon_sum_site",
    "Select a Site:",
    multiple = TRUE,
    sharedData = carbon_summary_shared,
    ~ site_code
  ),
  crosstalk::filter_select(
    "carbon_sum_param",
    "Select a Parameter:",
    multiple = TRUE,
    sharedData = carbon_summary_shared,
    ~ parameter
  )
)
DT::datatable(carbon_summary_shared) %>%
  DT::formatRound(columns = c("mean", "median", "sd", "min", "max"),
                  digits = 2)
carbon_summary
## # A tibble: 625 x 9
##    parameter    Site  WaterBody    site_code  mean median    sd   min   max
##    <chr>        <chr> <chr>        <chr>     <dbl>  <dbl> <dbl> <dbl> <dbl>
##  1 Total Carbon CC-01 Cedar Creek  CC-01S     57.2   59.6  10.5  59.6  72.9
##  2 Total Carbon FC-01 Fish Creek   FC-01S     59.3   63.9  15.6  63.9  88.3
##  3 Total Carbon FC-02 Fish Creek   FC-02S     57.8   57.7  15.8  57.7  96.7
##  4 Total Carbon HC-01 Honey Creek  HC-01S     48.9   51.1  15.5  51.1  81.9
##  5 Total Carbon HC-02 Honey Creek  HC-02S     49.0   52.2  15.6  52.2  85.5
##  6 Total Carbon HC-03 Honey Creek  HC-03S     48.2   50.2  15.1  50.2  79.6
##  7 Total Carbon HC-04 Honey Creek  HC-04S     56.8   55.5  22.3  55.5  99.6
##  8 Total Carbon HC-05 Honey Creek  HC-05S     56.2   55.8  19.3  55.8  94.2
##  9 Total Carbon IC-01 Indian Creek IC-01S     56.4   58.7  20.4  58.7  89.2
## 10 Total Carbon IC-02 Indian Creek IC-02S     54.5   55.8  20.2  55.8  95.1
## # ... with 615 more rows



Seasonal Carbon Boxplots


Plot Description Seasonal summaries of carbon data. Use the dropdowns to select waterbody and parameter.

carbon_data <- wq_data_long %>%
  dplyr::filter(grepl('Carbon', parameter))

carbon_shared <- crosstalk::SharedData$new(carbon_data)

bscols(
  crosstalk::filter_select(
    "carbon_site",
    "Select a Waterbody:",
    multiple = FALSE,
    sharedData = carbon_shared,
    ~ water_body
  ),
  crosstalk::filter_select(
    "carbon_param",
    "Select a Parameter:",
    multiple = FALSE,
    sharedData = carbon_shared,
    ~ parameter
  )
)
plotly::plot_ly(
  data = carbon_shared,
  y = ~ reading_raw,
  x = ~ month,
  type = 'box'
)


Carbon Boxplots by Site


Plot Description Site specific summaries of carbon data. Use the dropdowns to select site and parameter.

carbon_data <- wq_data_long %>%
  dplyr::filter(grepl('Carbon', parameter))

carbon_shared <- crosstalk::SharedData$new(carbon_data)

bscols(
  crosstalk::filter_select(
    "carbon_site",
    "Select a Waterbody:",
    multiple = FALSE,
    sharedData = carbon_shared,
    ~ water_body
  ),
  crosstalk::filter_select(
    "carbon_param",
    "Select a Parameter:",
    multiple = FALSE,
    sharedData = carbon_shared,
    ~ parameter
  )
)
plotly::plot_ly(
  data = carbon_shared,
  y = ~ reading_raw,
  x = ~ sitecode,
  color = ~ carbon_site_flag,
  type = 'box'
)


CP by Site


cp_data <- wq_data_long %>%
  dplyr::filter(grepl('Carbon', parameter),
                grepl('CP', survey_num))

cp_shared1 <- crosstalk::SharedData$new(cp_data)

bscols(
  crosstalk::filter_select(
    "cp_param1",
    "Select a Parameter:",
    multiple = FALSE,
    sharedData = cp_shared1,
    ~ parameter
  ),
  
  crosstalk::filter_select(
    "cp_source1",
    "Select a Source Code:",
    multiple = TRUE,
    sharedData = cp_shared1,
    ~ source_code_sid
  )
)
plotly::plot_ly(
  data = cp_shared1,
  y = ~ reading_raw,
  x = ~ sitecode,
  color = ~ carbon_site_flag,
  type = 'box'
)


Seasonal CP
cp_data <- wq_data_long %>%
  dplyr::filter(grepl('Carbon', parameter),
                grepl('CP', survey_num))

cp_shared2 <- crosstalk::SharedData$new(cp_data)

bscols(
  crosstalk::filter_select(
    "carbon_site",
    "Select a Waterbody:",
    multiple = TRUE,
    sharedData = cp_shared2,
    ~ water_body
  ),
  crosstalk::filter_select(
    "carbon_param",
    "Select a Parameter:",
    multiple = FALSE,
    sharedData = cp_shared2,
    ~ parameter
  )
)
plotly::plot_ly(
  data = cp_shared2,
  y = ~ reading_raw,
  x = ~ month,
  type = 'box'
)


Site Map


leaflet() %>%
  addPolygons(
     data = mmsd_wq_sites %>%
       st_as_sf(coords = c("Longitude", "Latitude"), crs = 4326) %>%
       st_transform(crs = 3071) %>%
       st_buffer(dist = 500) %>%
       st_transform(crs = 4326)%>%
       filter(usgs_eco_site_flag == "yes"),
     popup = ~Site,
     color = "green"
   ) %>%
   addPolygons(
     data = mmsd_wq_sites %>%
       st_as_sf(coords = c("Longitude", "Latitude"), crs = 4326) %>%
       st_transform(crs = 3071) %>%
       st_buffer(dist = 500) %>%
       st_transform(crs = 4326)%>%
       filter(usgs_eco_site_flag == "no"),
     popup = ~Site,
     color = "red"
   ) %>%
   addProviderTiles(provider = providers$Esri.NatGeoWorldMap)%>%
   addPolygons(
     data =usgs_stream_gauges%>%
       st_as_sf(coords = c("Longitude", "Latitude"), crs = 4326) %>%
       st_transform(crs = 3071) %>%
       st_buffer(dist = 500) %>%
       st_transform(crs = 4326),
     color = 'blue',
     popup = ~paste(usgs_site_no, "<br>",station_nm))%>%
   addLegend("bottomright", 
             colors =c("red",  "green", "blue"),
             labels = c("mmsd - no eco","mmsd - eco","usgs gage"))



Site MDS


Carbon / Site Multidimensional Scaling

Multidimensional scaling was used to find similarities between stations. Data used in this analysis included:
Carbon species (TC,TOC,TDOC,TIC) River data (source code 901) Year range = 2016 -2020 Site not included: RI-38, RI-15, RI-19, RI-18

Parameter data for a survey were only included if there were no missing records between sites. For example if one site did not have TOC data for a given survey, all TOC data for that survey was removed.

once the data were filtered, euclidan distance was calculated using the “dist()” function in R. A MDS was then performed using the "cmdscale() function in R. Both functions are from the base stats package in R.

Finally, the results of the MDS analysis were plotted and sites were color coded by waterbody. A site map is also found below for reference.



River

Data Description

Years included: = 2016-2020
Source Code: = 901 or 1004
Sites excluded: = “RI-38”,“RI-15”,“RI-19”,“RI-18”

River Site Dendrogram and Multidimensional Scaling Plots

#filter and calculate distance matrix 
data_clean <-
  wq_data_long %>%
  filter(
    grepl("Carbon", parameter) &
      !grepl("CP", survey_num) &
      source_code_sid %in% c(901, 1004) &
      depth == "S" &
      lubridate::year(collection_date) > 2015 &
      !sitecode %in% c("RI-38", "RI-15", "RI-19", "RI-18")
  ) %>%
  mutate(survey_parameter = paste(parameter,
                                  as.numeric(collection_date),
                                  sep = "_")) %>%
  select(survey_parameter,
         reading_raw,
         sitecode) %>%
  pivot_wider(names_from = "survey_parameter",
              values_from = "reading_raw") %>%
  select_if(~ !any(is.na(.))) 

dist <- calculate_dist(data_clean)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))

print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

wq_data_long %>%
  filter(
      grepl("Carbon", parameter) &
      !grepl("CP",survey_num) &
           source_code_sid %in% c(901,1004) &
        depth == "S" &
        lubridate::year(collection_date) > 2015 &
        !sitecode %in% c("RI-38","RI-15","RI-19","RI-18")) %>%
    mutate(date_parameter = paste(parameter,
                                    as.numeric(collection_date),
                                    sep = "_")) %>%
  mutate(date_parameter = paste(parameter, collection_date, sep = "_")) %>%
  select(date_parameter,
           reading_raw,
           sitecode) %>%
    pivot_wider(names_from = "date_parameter",
                values_from = "reading_raw") %>%
    select_if( ~ !any(is.na(.))) %>%
  pivot_longer(cols = 2:ncol(.), names_to = "date_parameter") %>%
  tidyr::separate(date_parameter,
                  into = c("parameter", "date"),
                  sep = "_") %>% 
  mutate(collection_date = lubridate::ymd(date))%>% 
  left_join((
    wq_data_long %>%
      select(survey_num,collection_date)%>%
      mutate(collection_date = lubridate::ymd(collection_date))%>%
      distinct()
    )) %>% 
  mutate(year = lubridate::year(collection_date)) %>%  
  group_by(year, survey_num, parameter) %>%
  count() %>%
  DT::datatable(
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))
  )


CP

Data Description

Years included: = 2015-2020
Sites excluded: = All OH and “RI-38”,“CC-01”,“RI-15”,“RI-18”,“RI-19” Survey Excluded: = CP 060

CP Site Dendrogram and Multidimensional Scaling Plots

dist <- wq_data_long %>%
    filter(
      grepl("Carbon", parameter) &
        grepl("CP",survey_num) &
        survey_num != "CP 060" &
        !grepl("OH",sitecode) &
        !sitecode %in% c("RI-38","CC-01","RI-15","RI-18","RI-19") &
        depth == "S" &
        lubridate::year(collection_date) > 2014
    ) %>%
    mutate(survey_parameter = paste(parameter,
                                    survey_num,
                                    sep = "_")) %>% 
    arrange(survey_num)%>%
    select(survey_parameter,
           reading_raw,
           sitecode) %>% 
    pivot_wider(names_from = "survey_parameter",
                values_from = "reading_raw",
                id_cols = "sitecode") %>% 
   column_to_rownames("sitecode")%>%
    select_if( ~ !any(is.na(.))) %>% 
    dist() 

p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))

print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(wq_data_long%>%
    filter(
      grepl("Carbon", parameter) &
        grepl("CP",survey_num) &
        survey_num != "CP 060" &
        !grepl("OH",sitecode) &
        !sitecode %in% c("RI-38","CC-01","RI-15","RI-18","RI-19") &
        depth == "S" &
        lubridate::year(collection_date) > 2014
    ) %>%
  mutate(survey_parameter = paste(parameter,survey_num,sep = "_"))%>%
  select(survey_parameter,
         reading_raw,
         sitecode)%>%
  pivot_wider(names_from = "survey_parameter",
              values_from = "reading_raw")%>%
  select_if(~ !any(is.na(.)))%>%
  pivot_longer(cols = 2:ncol(.),names_to = "survey_parameter")%>%
  tidyr::separate(survey_parameter,into =c("parameter","survey"),sep = "_")%>%
  left_join((wq_data_long%>%
              select(survey_num,
                     collection_date)%>%
              rename(survey = survey_num)%>%
              distinct()))%>%
  mutate(year = lubridate::year(collection_date))%>%
  group_by(year,survey,parameter)%>%
  count()%>%
     DT::datatable(
      extensions = 'Buttons',
      selection = list(target = 'column'),
      options = list(
        buttons = c('copy', 'csv', 'excel'))))


Outer Harbor

Outer Harbor Site Dendrogram and Multidimensional Scaling Plots

clean_data <- prep_data(source_code =900)
dist <- calculate_dist(clean_data)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))
print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(DT::datatable(
    dist_data_input(clean_data),
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))))

South Shore

South Shore Site Dendrogram and Multidimensional Scaling Plots

clean_data <- prep_data(source_code =902)
dist <- calculate_dist(clean_data)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))
print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(DT::datatable(
    dist_data_input(clean_data),
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))))

Underwood Creek

River Site Dendrogram and Multidimensional Scaling Plots

clean_data <- prep_data(source_code =c(931))
dist <- calculate_dist(clean_data)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))
print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(DT::datatable(
    dist_data_input(clean_data),
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))))

Honey Creek

Honey Creek Site Dendrogram and Multidimensional Scaling Plots

clean_data <- prep_data(source_code =c(939))
dist <- calculate_dist(clean_data)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))
print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(DT::datatable(
    dist_data_input(clean_data),
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))))

Oak Creek

Oak Creek Site Dendrogram and Multidimensional Scaling Plots

clean_data <- prep_data(source_code =c(924))
dist <- calculate_dist(clean_data)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))
print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(DT::datatable(
    dist_data_input(clean_data),
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))))

Root River

Root River Site Dendrogram and Multidimensional Scaling Plots

clean_data <- prep_data(source_code =c(935))
dist <- calculate_dist(clean_data)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))
print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(DT::datatable(
    dist_data_input(clean_data),
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))))

Quad Creek

Quad Creek Site Dendrogram and Multidimensional Scaling Plots

clean_data <- prep_data(source_code = c(929,936,940,941))
dist <- calculate_dist(clean_data)
p1 <- suppressMessages(dendro_plot(dist))
p2 <-suppressMessages(mds_plot(dist))
print(cowplot::plot_grid(p1,p2,scale = 0.95,ncol = 1,rel_widths = c(0.7,1)))

suppressMessages(DT::datatable(
    dist_data_input(clean_data),
    extensions = 'Buttons',
    selection = list(target = 'column'),
    options = list(buttons = c('copy', 'csv', 'excel'))))



Site Map

mmsd.wq::leaflet_site_map(site_photos = TRUE)